<?php
namespace app\operator\controller;
use think\Db;
use EasyWeChat\Foundation\Application;
use EasyWeChat\Payment\Order;
class Wechat
{
    
    //获取poenid
    public function getopenid()
    {
    	$url = 'https://api.weixin.qq.com/sns/jscode2session';
    	$data['appid'] = config('OperatorWchat.AppID');
    	$data['secret'] = config('OperatorWchat.AppSecret');
    	$data['js_code'] =input('param.code');//Request::instance()->get('code');
    	$data['grant_type'] ='authorization_code';

    	$userinfo = CURLRequest($url,$data);

        
    	if(isset($userinfo['openid'])){
    		$res['ukey'] = mwencrypt($userinfo['openid']);
            $oid = Db::name('operator_users')->where('openid',$userinfo['openid'])->field('oid')->find();
            $res['oid'] = $oid['oid'];

            return $res;
    	}else{
            return '';
        }
    	

        
        //$key =    encrypt($result['openid']);
        //return $key;
    	
     
    }

}
